#include <list>
#include <mutex>
#include <iostream>
#include <algorithm>
#include <thread>

std::list<int> num_list;
std::mutex list_mutex;

void add_num_2_list(int new_value)
{
    std::lock_guard<std::mutex> guard(list_mutex);
    num_list.push_back(new_value);
}

void list_contains(int find_value)
{
    std::scoped_lock lock(list_mutex);  //c++17
    std::cout << (std::find(num_list.begin(), num_list.end(), find_value) != num_list.end());   
}

int main()
{
    std::thread add_thread(add_num_2_list, 4);
    std::thread contains_thread(list_contains, 1);

    add_thread.join();
    contains_thread.join();
    
    return 0;               
}
